package com.fyy.socket.tcp.upload;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;

/**
 * @Author fyy
 * @Description 文件拷贝
 * @Date 2020/12/15 15:19
 */
public class CopyFile {

    public static void main(String[] args) {
        String sFilePath = "F:\\test.txt";
        String dFilePath = "F:\\test2.txt";

        try ( //创建文件输入输出流
                BufferedInputStream bis = new BufferedInputStream(new FileInputStream(sFilePath));
                BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(dFilePath));
        ){
            //读取文件
            byte[] buf = new byte[1024];
            int len;
            while ((len = bis.read(buf)) != -1){
                bos.write(buf,0,len);
            }
        }catch (Exception e){
            e.printStackTrace();
        }

    }

}
